﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Shop.Web.Models.Passport;
using Shop.Service.Customers;
using Shop.Core.Domain.Customers;

namespace Shop.Web.Controllers
{
    public class PassportController : Controller
    {
        ICustomerService CustomerService
        {
            get;
            set;
        }

        public PassportController(ICustomerService customerService)
        {
            this.CustomerService = customerService;
        }

        //public ActionResult Register
        [HttpGet]
        public ActionResult Register()
        {
            return View("Register");
        }
        [HttpPost]
        public ActionResult Register(RegisterModel model)
        {
            CreateCustomerRequest request = new CreateCustomerRequest()
            {
                Email = model.Email,
                NickName = model.NickName,
                Password = model.Password
            };
            Customer customer = this.CustomerService.CreateCustomer(request);
            return View("RegisterSuccess", customer);
        }
        //
        // GET: /Passport/
        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Passport/Details/5
        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Passport/Create
        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Passport/Create
        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Passport/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Passport/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Passport/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Passport/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}